package com.lanhai.webservice.netty;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;

import java.util.List;

public class ByteToNbMessageDecoder  extends ByteToMessageDecoder {
    @Override
    protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list) throws Exception {
    //这里协商具体的解析代码
 //       deal(byteBuf,list,channelHandlerContext);
        System.out.println("解码器");
    }

    @Override
    public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
        super.channelRegistered(ctx);
        System.out.println("连接成功");
    }



    /**
     * 断开连接处理
     * @param ctx
     * @throws Exception
     */
    @Override
    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
        disconnect();
        super.channelInactive(ctx);
    }

    //断开连接处理
    public void disconnect(){
        System.out.println("断开连接！");
    }

}
